#pragma once

#ifndef GRAPHEDITOR_H
#define GRAPHEDITOR_H

#include <QWidget>
#include <memory>
#include "../IModelEditor.h"
#include "GraphScene.h"

QT_BEGIN_NAMESPACE
class QToolBar;
class QGraphicsView;
class QGraphicsLineItem;
class QToolButton;
QT_END_NAMESPACE

class GraphScene;

class GraphEditor :
	public QWidget, public IModelEditor
{
	Q_OBJECT
private:
	bool _readOnly;
public:
	GraphEditor(bool readOnly);
	~GraphEditor(void);

	void paintEvent(QPaintEvent *);

	
	bool dirty();
	void setDirty(bool dirty);
	const QString& fileFilter();
	void clear();
	bool save(const QString& path);
	bool load(const QString& path);
	SemanticModel::ModelPtr generateModel();
	void setModel(const SemanticModel::Model& m);
	void switchMode(GraphScene::Mode mode);
private:
	void createToolbars();
	void createView();

	QToolBar *_paletteToolbar;
	QGraphicsView *_view;
	GraphScene *_scene;

	QToolButton* moveButton;
	QToolButton* addClassButton;
	QToolButton* addOperationButton;
	QToolButton* addRelationButton;	

private slots:
	void goToMode(int modeIndex);
};

#endif // GRAPHEDITOR_H
